VERSION="v0.1"

# 下载 containerd 并解压
CONTAINERD_URL=https://gitee.com/jiang-zhida/containerd-deploy/releases/download/$VERSION/containerd-linux-amd64.tar.gz
wget $CONTAINERD_URL 
tar Cxzvf /usr/local containerd-linux-amd64.tar.gz

# containerd 添加 systemd 启动
mkdir -p /usr/local/lib/systemd/system
curl https://gitee.com/jiang-zhida/containerd-deploy/raw/master/containerd.service -o /usr/local/lib/systemd/system/containerd.service
systemctl daemon-reload && systemctl enable --now containerd

# 安装 runc
RUNC_URL=https://gitee.com/jiang-zhida/containerd-deploy/releases/download/$VERSION/runc.amd64
wget $RUNC_URL 
install -m 755 runc.amd64 /usr/local/sbin/runc

# 下载 cni-plugins 并解压
CNI_PLUGINS_URL=https://gitee.com/jiang-zhida/containerd-deploy/releases/download/$VERSION/cni-plugins-linux-amd64.tgz
mkdir -p /opt/cni/bin
wget $CNI_PLUGINS_URL 
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64.tgz

# 生成 containerd 配置文件
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
systemctl restart containerd

# 清理下载包
rm containerd-linux-amd64.tar.gz runc.amd64 cni-plugins-linux-amd64.tgz